Skip to content

Use __init__ if we have it instead of the actual type.#20208

Closed
noobCodec wants to merge 4 commits intopython:masterfrom
noobCodec:bug_fix
Closed

Use __init__ if we have it instead of the actual type.#20208
noobCodec wants to merge 4 commits intopython:masterfrom
noobCodec:bug_fix

Conversation

@noobCodec
Copy link
Copy Markdown

This pull request fixes #20016.

Updated pretty_callable to use the definition name if it matches 'init' instead of the type name for consistency. Not sure if this is correct, but appears to be what the issue is calling for.

Updated TC "testSerializeOverloaded__init__" to account for this change.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 8, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Collaborator

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this is the right level to solve the issue at.

Comment thread mypy/messages.py
):
s = f"{definition.name}({s})"
else:
s = f"{tp.name.split()[0]}({s})" # skip "of Class" part
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure this is the right approach? Like, obviously this works. But I feel like the issue only being produced with cache means we're forgetting to cache some attribute, which might cause more issues than just this!

Do you know what exactly differs between the object in the first and the second runs that causes the printing to be different before?

Comment thread mypy/test/config.py
PREFIX = provided_prefix
else:
this_file_dir = os.path.dirname(os.path.realpath(__file__))
this_file_dir = os.path.dirname(os.path.abspath(__file__))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the same thing, I think? To be honest I think this should probably use pathlib instead (seriously? 3 os.path.dirnames? That's awful!)

But I think any improvements should be in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect method name in cached overload "note" messages

3 participants